<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播示例3</title>
    <!-- 第一步 引入swiper插件 css和js -->
    <link rel="stylesheet" href="https://unpkg.com/swiper@8/swiper-bundle.css">
    <style>
        /* 第三步： 设置轮播容器大小 */
        .swiper {
            width: 600px;
            height: 200px;
        }

        .swiper img {
            width: 600px;
            height: 200px;
        }
    </style>
</head>

<body>
    <!-- 第二步: 添加HTML内容 -->
    <div class="swiper">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <img src="../img/banner1.png" alt="banner1">
            </div>
            <div class="swiper-slide">
                <img src="../img/banner2.png" alt="banner2">
            </div>
            <div class="swiper-slide">
                <img src="../img/banner3.png" alt="banner3">
            </div>
        </div>

        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>
    </div>

    <script src="https://unpkg.com/swiper@8/swiper-bundle.js"> </script>
    <script>
        // 第四步: 初始化swiper
        new Swiper('.swiper', {
            loop: true, // 循环模式选项
            autoplay: { delay: 1000, }, //自动轮播
            effect: 'fade', // 切换效果
            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
            },
        })
    </script>
</body>

</html>